package com.haredot.controller;

import com.haredot.handler.TokenContextHolder;
import com.haredot.result.R;
import com.haredot.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/teacher")
public class TeacherController {

    @Resource
    private UserService userService ;


    @GetMapping("/list")
    public R<?> list() {
        return userService.queryTeachers();
    }

    @GetMapping("/coffee/verify")
    public R<?> verifyCoffeeOrderList() {
        // 获取教师ID
        Long userId = TokenContextHolder.getCurrentUser().getId();
        return userService.queryCoffeeList(userId);
    }

    @GetMapping("/coffee/detail/{cid}")
    public R<?> verifyCoffeeDetail(@PathVariable("cid") Long cid) {
        return userService.queryCoffeeDetail(cid);
    }

    @PutMapping("/coffee/verify/{cid}-{agree}")
    public R<?> verifyCoffee(@PathVariable("cid") Long cid, @PathVariable Integer agree) {
        return userService.verifyCoffee(cid, agree);
    }

    @DeleteMapping("/coffee/cancel/{cid}")
    public R<?> cancelCoffee(@PathVariable("cid") Long cid) {
        return userService.cancelCoffee(cid);
    }
}
